﻿package com.crl.core.config 
{
	import com.crl.core.config.impl.Configuration;
	import com.crl.core.config.impl.IConfiguration;
	
	import flash.utils.Dictionary;

	/**
	 * ...
	 * @author crl
	 */
	public class ConfigurationManager
	{
		private static var _appSettings:Dictionary;
		private static var _connectionStrings:Dictionary;
		
		private static var config:IConfiguration;
		public function ConfigurationManager() 
		{
			
		}
		
		public static function set configuration(conf:IConfiguration):void{
			config=conf;
		}
		
		
		/**
		 * 返回键值对;
		 */
		static public function get appSetting():Dictionary {
			if (_appSettings == null) {
				//_appSettings = new Dictionary();
				
				_appSettings=getSection("appSettings")  as Dictionary;
				
			}
			return _appSettings;
		}
		
		
		static public function get connectionStrings():Dictionary {
			if (_connectionStrings==null) {
				 _connectionStrings=getSection("connectionStrings") as Dictionary;
			}
			return _connectionStrings;
		}

		
		static public function getSection(sectionKey:String):Object {
			return getConfig().getSection(sectionKey);
		}
		
		static private function getConfig():IConfiguration {
			if (config == null) {
				config = new Configuration();
			}
			return config;
		}
	}

}